package com.kk.framework.util;

import java.io.File;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.FileSystemXmlApplicationContext;
//import org.springframework.web.context.ContextLoader;
//import org.springframework.web.context.WebApplicationContext;
//import org.springframework.web.context.support.WebApplicationContextUtils;

/**
 * 
 * SpringConext 工具类</br>
 * Description: 获取Sprint配置上下文(测试时候使用)
 * 
 */
public class SpringContextUtils {

	/*private static WebApplicationContext context;

	private SpringContextUtils() {
	}

	public static WebApplicationContext getApplicationContext() {
		if(null==context){
			initApplicationContext();
		}
		return context;
	}

	@SuppressWarnings("unchecked")
	public static <T> T getBean(Class<T> c) {
		String className = c.getSimpleName();
		className = StringUtils.tofirstLowerCase(className, 1);
		T bean = (T) SpringContextUtils.getBean(className);
		return bean;
	}

	public static Object getBean(String beanid) {
		if (context == null) {
			initApplicationContext();
		}
		return context.getBean(beanid);
	}

	public static void setApplicationContext(WebApplicationContext context) {
		SpringContextUtils.context = context;

	}

	private static void initApplicationContext() {
		WebApplicationContext wac = ContextLoader.getCurrentWebApplicationContext(); 
		SpringContextUtils.context = wac;
	}             */
}
